package com.isman.placeslist;

import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TabHost;
import android.widget.TextView;

public class PagePeople extends TabActivity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.page_people);
		
		init();
		initData();
	}
	
	private void init() {
		vBtnFind = (Button)findViewById(R.id.btn_head_findprople);
		vBtnFind.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View arg0) {
				startActivity(new Intent(PagePeople.this, PagePeopleFind.class));
			}
		});
	}
	private void initData(){
		addLeft("Friend List", TabPeopleList.class);		
		addRight("Friend Request", TabPeopleRequest.class) ;	
	}
	private void addLeft(String labelId, Class<?> c){
		TabHost tabHost = getTabHost();
		Intent intent = new Intent(this, c);
		TabHost.TabSpec spec = tabHost.newTabSpec("tab" + labelId);	
		
		View tabIndicator = LayoutInflater.from(this).inflate(R.layout.inc_tab_indicator, getTabWidget(), false);
		tabIndicator.setBackgroundResource(R.drawable.bg_tab_indicator_left);
		TextView title = (TextView)tabIndicator.findViewById(R.id.title);
		title.setText(labelId);
		
		spec.setIndicator(tabIndicator);
		spec.setContent(intent);
		tabHost.addTab(spec);
	}
	
	
	private void addRight(String labelId, Class<?> c){
		TabHost tabHost = getTabHost();
		Intent intent = new Intent(this, c);
		TabHost.TabSpec spec = tabHost.newTabSpec("tab" + labelId);	
		
		View tabIndicator = LayoutInflater.from(this).inflate(R.layout.inc_tab_indicator, getTabWidget(), false);
		tabIndicator.setBackgroundResource(R.drawable.bg_tab_indicator_right);
		TextView title = (TextView)tabIndicator.findViewById(R.id.title);
		title.setText(labelId);
		
		spec.setIndicator(tabIndicator);
		spec.setContent(intent);
		tabHost.addTab(spec);
	}

	private Button vBtnFind;
}
